package com.cta.tcp.server;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.cta.jms.MessageProducer;

public class TCPServerHandler extends IoHandlerAdapter {

	private Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	private MessageProducer producer;

	
	public void messageReceived(IoSession session, Object message)
			throws Exception {
		producer.sendMessages(message.toString());
		//logger.info(message.toString());
	}
	
	public void sessionCreated(IoSession session) throws Exception {
		logger.info("Session Created");
    }

    public void sessionOpened(IoSession session) throws Exception {
    	logger.info("Session Opened");
    }

    public void sessionClosed(IoSession session) throws Exception {
    	logger.info("Session Closed");
    }
}
